import Buff from '@/Buff';
import BuffUtil from '@/BuffUtil';
import SelectUtil from '@/SelectUtil';
import BuffCommon from 'code/Core/Common/BuffCommon';
import UnitCommon from 'code/Core/Common/UnitCommon';
import AbilityBase from 'code/Scripts/Abilities/base/AbilityBase';
/**
 * 献祭
 **/
export default class SS_Sacrifice extends AbilityBase {
    static instance: SS_Sacrifice;
    buffType: AppBuffType = {
        id: 'buff_SS_Sacrifice',
        art: this.art,
        name: this.abilityName,
        ubertip: '持续对周围的敌人造成火焰伤害',
        dur: 12,
        onInterval: this.buffInterval.bind(this),
        interval: 1,
        targetArt: 'Abilities\\Spells\\NightElf\\Immolation\\ImmolationTarget.mdl',
        targetAttach: 'origin',
        isDebuff: true,
    };
    constructor(id: string = 'Axj1') {
        super(id);
        SS_Sacrifice.instance = this;
        this.init();
        se.onUnitSpellEffect(this.onSpellEffect.bind(this), this.id);
    }
    init() {
        BuffUtil.registerBuffType(this.buffType);
    }
    cast<T extends Object = any>(tarX: number, tarY: number, source: unit, target: unit, data?: T): void {
        // BuffUtil.addBuff(target, this.buffType.id, source);
        BuffCommon.addBuff({ target, caster: source, buffTypeId: this.buffType.id, ablityId: this.id });
    }
    onSpellEffect() {
        this.cast(GetSpellTargetX(), GetSpellTargetY(), GetTriggerUnit(), GetSpellTargetUnit());
    }
    buffInterval(buff: Buff) {
        let lv = this.getAbilityLevel(buff.getCaster());
        let dmg = 23 * lv + UnitCommon.取法强(buff.getCaster()) * (0.8 + 0.5 * lv);
        DamageSystemInstance.applyFireDamage(buff.getParent(), buff.getCaster(), dmg / 2, this.id, true);
        let es = SelectUtil.getEnemyUnitsInRange(buff.getCaster(), 275, GetUnitX(buff.getParent()), GetUnitY(buff.getParent()));
        for (let e of es) {
            DamageSystemInstance.applyFireDamage(e, buff.getCaster(), dmg / 2, this.id);
            DestroyEffect(AddSpecialEffectTarget('Abilities\\Spells\\NightElf\\Immolation\\ImmolationDamage.mdl', e, 'overhead'));
        }
    }
}
